home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
015
/
softad.arc
/
WIDTHS.PAS
< prev
Wrap
Pascal/Delphi Source File
|
1987-01-07
|
15KB
|
438 lines
{$G2048,P512,D-}
program widths;
{-----------------------------------------------------------------------}
{ }
{ Program to Extract Width Table from HP Font Files }
{ }
{ widths SOURCE DESTINATION }
{ (using DOS redirection facilities) }
{ }
{-----------------------------------------------------------------------}
label
QUIT;
type
Str64 = string[64] ;
{--------------- Font Descriptor -------------------------------------}
FontMap = record
{+ 0} Res0: integer;
{+ 2} Res1: byte;
{+ 3} FontType: byte;
{+ 4} Res2: integer;
{+ 6} Baseline: integer;
{+ 8} CellWidth: integer;
{+10} CellHeight: integer;
{+12} Orientation: byte;
{+13} FixedProp: byte;
{+14} SymbolSet: integer;
{+16} Pitch: integer;
{+18} Height: integer;
{+20} Res3: integer;
{+22} Res4: byte;
{+23} Style: byte;
{+24} StrokeWeight: byte;
{+25} Typeface: byte;
end;
{--------------- Character Descriptor --------------------------------}
CharMap = record
{+ 0} Res0: integer;
{+ 2} Res1: integer;
{+ 4} Orientation: char;
{+ 5} Res2: byte;
{+ 6} LeftOffset: integer;
{+ 8} TopOffset: integer;
{+10} CharWidth: integer;
{+12} CharHeight: integer;
{+14} DeltaX: integer;
end;
HpFont = record
case Boolean of
True: (Tab: array[0..25] of Char);
False: (Def: FontMap);
end;
HpChar = record
case Boolean of
True: (Tab: array[0..15] of Char);
False: (Def: CharMap);
end;
Var
CC, i, j, k : integer;
Rpitch, Rsize : real;
Str2 : string[2];
FontDesc : HpFont;
CharDesc : HpChar;
Wtab : array[32..255] of Byte;
Nextc : char;
Char1, Char2, Char3 : char;
NumStr : string[5];
Skip : integer;
CharCode : integer;
CharCount : integer;
MemUsed : real;
const
OrMap : array[0..1] of string[10] = ('Portrait', 'Landscape');
SpMap : array[0..1] of string[12] = ('Fixed', 'Proportional');
StMap : array[0..1] of string[7] = ('Upright', 'Italic');
TyMap : array[0..10] of string[15] = ('Line Printer',
'Pica',
'Elite',
'Courier',
'Helv',
'TmsRmn',
'Gothic',
'Script',
'Prestige',
'Caslon',
'Orator');
SwMap : array[0..15] of string[12] = ('Normal','Normal+','Bold-','Bold',
'Bold+','Bold++','HiBold-','HiBold',
'Normal','Normal-','Light-','Light',
'Light+','Light++','LoLight-','LoLight');
SwiMap: array[0..15] of integer = (0,1,2,3,4,5,6,7,0,-1,-2,-3,-4,-5,-6,-7);
FtMap : array[0..1] of string[5] = ('7-Bit', '8-Bit');
FtSet : array[0..1] of integer = (128, 256);
TrMap : array[128..175] of integer = (180, 207, 197, 192,
204, 200, 212, 181,
193, 205, 201, 221,
209, 217, 216, 208,
220, 215, 211, 194,
206, 202, 195, 203,
239, 218, 219, 191,
187, 188, 80, 190,
196, 213, 198, 199,
183, 182, 249, 250,
185, 169, 170, 248,
247, 184, 251, 253);
function GetTyMap(arg:byte): Str64 ;
var
TyStr : Str64;
begin
TyStr := '*** not known';
if arg < 11
then TyStr := 'HP ' + TyMap[arg]
else case arg of
17: TyStr := 'BitStream ZapfHumanist' ;
18: TyStr := 'BitStream ItcGaramond' ;
19: TyStr := 'BitStream CooperBlack' ;
20: TyStr := 'BitStream CoronetBold' ;
21: TyStr := 'BitStream Broadway' ;
22: TyStr := 'BitStream BodiniBlack' ;
23: TyStr := 'BitStream CenturySchool' ;
24: TyStr := 'BitStream UniversityRoman' ;
106: TyStr := 'Softcraft RomanFixWidth' ;
112: TyStr := 'Softcraft SansSerif' ;
113: TyStr := 'Softcraft SansCompressed' ;
117: TyStr := 'Softcraft Classic' ;
118: TyStr := 'Softcraft Roman' ;
132: TyStr := 'Softcraft Script' ;
133: TyStr := 'Softcraft UnslantedItalic' ;
137: TyStr := 'Softcraft Formal' ;
138: TyStr := 'Softcraft Nouveau' ;
139: TyStr := 'Softcraft Modern' ;
140: TyStr := 'Softcraft Greek' ;
142: TyStr := 'Softcraft Hebrew' ;
143: TyStr := 'Softcraft Cyrillic' ;
149: TyStr := 'Softcraft Tall' ;
151: TyStr := 'Softcraft Twist' ;
152: TyStr := 'Softcraft OldEnglish' ;
153: TyStr := 'Softcraft Calligrapher' ;
154: TyStr := 'Softcraft Shadow' ;
155: TyStr := 'Softcraft Computer' ;
156: TyStr := 'Softcraft ClassicSymbols' ;
157: TyStr := 'Softcraft MathSymbols' ;
158: TyStr := 'Softcraft Accents' ;
else ;
end ;
GetTyMap := TyStr;
end;
function GetSymbolSet(arg:integer): Str64 ;
var
SyStr : Str64;
begin
SyStr := '*** not known' ;
case arg of
277: SyStr := '8U ==> Roman-8' ;
267: SyStr := '8K ==> Roman-8' ;
269: SyStr := '8M ==> Roman-8' ;
21: SyStr := '0U ==> USASCII' ;
2: SyStr := '0B ==> Line Draw' ;
1: SyStr := '0A ==> Math Symbols' ;
53: SyStr := '1U ==> US Legal' ;
5: SyStr := '0E ==> Roman Extension' ;
4: SyStr := '0D ==> ISO Denmark/Norway' ;
37: SyStr := '1E ==> ISO United Kingdom' ;
6: SyStr := '0F ==> ISO France' ;
7: SyStr := '0G ==> ISO German' ;
9: SyStr := '0I ==> ISO Italy' ;
19: SyStr := '0S ==> ISO Sweden/Finland' ;
51: SyStr := '1S ==> ISO Spain' ;
else ;
end;
GetSymbolSet := SyStr;
end;
function GetStrVal(arg:integer): Str64 ;
var
SyStr : Str64;
begin
SyStr := '';
if arg > 0
then Str(arg, Systr);
GetStrVal := SyStr;
end;
begin
WriteLn(Con, 'WIDTHS v1.01');
WriteLn(Con, 'Denis DeLaRoca, 1987');
WriteLn('=================================================================');
WriteLn('');
{------ Make Sure File starts with Font Desc: "^[)s" ----------------}
read(Char1, Char2, Char3);
if (Char1 <> #$1b) or (Char2 <> ')') or (Char3 <> 's')
then begin
writeln('*** Missing Font Descriptor');
halt(1);
end;
{------ Extract Length of Descriptor + Data ------------------------}
NumStr := '';
read(Nextc);
while nextc <> 'W' do
begin
NumStr := NumStr + nextc;
read(nextc);
end;
Val(NumStr, Skip, CC);
if CC <> 0
then begin
writeln('*** Bad Font Descriptor Length');
halt(2);
end;
{------ Read Font Descriptor Header and Output Some Parms ----------}
for i := 0 to 25
do read(FontDesc.Tab[i]);
with FontDesc, Def do
begin
CellWidth := Swap(CellWidth);
CellHeight := Swap(CellHeight);
Pitch := Swap(Pitch);
BaseLine := Swap(BaseLine);
SymbolSet := Swap(SymbolSet);
Height := Swap(Height);
WriteLn('Symbol Set = ', SymbolSet, ' ==> ', GetSymbolSet(SymbolSet));
WriteLn('Font Type = ', FtMap[FontType]);
WriteLn('Typeface = ', Typeface, ' ==> ', GetTyMap(Typeface)) ;
WriteLn('Orientation = ', OrMap[Orientation]);
WriteLn('Style = ', StMap[Style]);
WriteLn('Weight = ', SwiMap[StrokeWeight], ' ==> ', SwMap[StrokeWeight]);
WriteLn('Spacing = ', SpMap[FixedProp]);
WriteLn('Cell Width = ', CellWidth, ' dots');
WriteLn('Cell Height = ', CellHeight, ' dots');
WriteLn('BaseLine = ', BaseLine, ' dots from top');
Write ('Default HMI = ', Round(Pitch/4), ' dots');
WriteLn(', or ', Round(1200/Pitch), ' pitch');
Write ('Font Height = ', Height div 4, ' dots');
WriteLn(', ', Round((Height*3)/50), ' point-size');
{Round((Height*72)/1200)}
Rpitch := (1200.0 / Pitch) + 0.005;
Rsize := ((Height * 72.0) / 1200.0) + 0.005;
WriteLn('Real Pitch = ', Rpitch:5:2, ' cpi');
WriteLn('Real Size = ', Rsize:5:2, ' pts');
Write ('Font Select = ');
Write('^[&I', GetStrVal(Orientation), 'O');
Str2 := GetSymbolSet(SymbolSet);
Write('^[(', Str2);
Write('^[(s', GetStrVal(FixedProp), 'p');
if FixedProp = 0
then Write(Round(1200/Pitch), 'h');
Write(Round((Height*3)/50), 'v');
{Round((Height*72)/1200)}
Write(GetStrVal(Style), 's');
Write(GetStrVal(SwiMap[StrokeWeight]), 'b');
WriteLn(GetStrVal(Typeface), 'T');
end;
{------ Initialize Widths Table ------------------------------------}
for i := 32 to 255
do Wtab[i] := Round(FontDesc.Def.Pitch/4);
for i := 128 to 160
do Wtab[i] := 0;
{------ Now Skip Rest of Font Descriptor Data ------------------------}
Skip := Skip - 26;
for i := 1 to skip
do Read(Nextc);
{------ Now Start Main Loop, Extracting Char Widths -----------------}
CharCount := 0;
repeat
repeat
read(Char1);
until (Char1 = #$1b);
read(Char2, Char3);
until (Char2 = '*') and (Char3 = 'c');
{------ Validate Char Code Descriptor --------------------------------}
while ((not EOF) and (Char1 <> #$00)) do
begin
if (Char1 <> #$1b) or (Char2 <> '*') or (Char3 <> 'c')
then begin
writeln('*** Bad Char Code Desc');
halt(3);
end;
{------ Count Number of Character Descriptors in Font -----------------}
CharCount := CharCount + 1;
{------ Extract Char Code Value --------------------------------------}
NumStr := '';
Read(Nextc);
while nextc <> 'E' do
begin
NumStr := NumStr + Nextc;
Read(Nextc);
end;
Val(NumStr, CharCode, CC);
{------ Validate Char Font Descriptor -------------------------------}
Read(Char1,Char2, Char3);
if (Char1 <> #$1b) or (Char2 <> '(') or (Char3 <> 's')
then begin
writeln('*** Bad Char Descriptor');
halt(4);
end;
{------ Extract Length of Descriptor + Data -------------------------}
NumStr := '';
Read(Nextc);
while nextc <> 'W' do
begin
NumStr := NumStr + Nextc;
Read(Nextc);
end;
Val(NumStr, Skip, CC);
{------ Read Char Font Descriptor ------------------------------------}
for i := 0 to 15
do Read(CharDesc.Tab[i]);
with CharDesc, Def do
begin
LeftOffset := Swap(LeftOffset);
TopOffset := Swap(TopOffset);
CharWidth := Swap(CharWidth);
CharHeight := Swap(CharHeight);
Deltax := Swap(Deltax);
Wtab[CharCode] := Deltax div 4; {--- Char Width ----------}
end;
{------ Skip Char Font Data ------------------------------------------}
Skip := Skip - 16;
for i := 1 to Skip
do Read(Nextc);
{------ Try to Fetch Next Char Code Descriptor ----------------------}
Read(Char1, Char2, Char3);
end;
{------ Output: # Char Descriptors + Font Memory Utilization ---------}
with FontDesc, Def do
begin
WriteLn('Font Chars = ', CharCount, ' chars defined in font');
{ i := (((CellWidth - 1) div 8) + 1);
j := (((CellHeight - 1) div 8) + 1);
MemUsed := FtSet[FontType]*64*(((i*j-1)/64)+1);
WriteLn('Memory Use = ', MemUsed:6:0, ' bytes of LaserJet+ memory'); }
end;
{------ If Font is fixed-spaced then we are done --------------------}
if FontDesc.Def.FixedProp = 0
then goto QUIT;
{------ Now Output Char Widths Table (MS Word Format) ---------------}
WriteLn('');
WriteLn('{Wn');
if (FontDesc.Def.FontType = 0)
then begin
i := 127;
k := 11;
end
else begin
i := 255;
k := 27;
end;
WriteLn('FontSize:',
Round((FontDesc.Def.Height*3)/25),' chFirst:32 chLast:',i);
for i := 0 to k do
begin
for j := 0 to 7 do
write(' ',32+i*8+j, ':', wtab[32+i*8+j], ' ');
writeln('');
end;
WriteLn('');
WriteLn('}W');
WriteLn('');
if (FontDesc.Def.FontType = 0)
then goto QUIT;
{------ Correct Widths of Char Range 128 to 175 ---------------------}
for i := 128 to 175 do
wtab[i] := wtab[TrMap[i]];
{------ Now Output Char Widths Table (MS Word Format) ---------------}
WriteLn('');
WriteLn('{Wn');
WriteLn('FontSize:',
Round((FontDesc.Def.Height*3)/25),' chFirst:32 chLast:175');
for i := 0 to 17 do
begin
for j := 0 to 7 do
write(' ',32+i*8+j, ':', wtab[32+i*8+j], ' ');
writeln('');
end;
WriteLn('');
WriteLn('}W');
WriteLn('');
QUIT:
end.